type LocalEnvironment {
  id: Int!
  globalId: ID!
  name: String!
  folderPath: String
  stopPath: String
  deletePath: String
  retryUrl: String
  autoStopPath: String
}

input LocalEnvironmentInput {
  id: Int!
  globalId: ID!
  name: String!
  folderPath: String
  stopPath: String
  deletePath: String
  retryUrl: String
  autoStopPath: String
}

type NestedLocalEnvironment {
  name: String!
  size: Int!
  latest: LocalEnvironment!
}

input NestedLocalEnvironmentInput {
  name: String!
  size: Int!
  latest: LocalEnvironmentInput!
}

type LocalEnvironmentFolder {
  environments: [LocalEnvironment!]!
  availableCount: Int!
  stoppedCount: Int!
}

type ReviewApp {
  canSetupReviewApp: Boolean!
  allClustersEmpty: Boolean!
  reviewSnippet: String
}

type LocalEnvironmentApp {
  stoppedCount: Int!
  availableCount: Int!
  environments: [NestedLocalEnvironment!]!
  reviewApp: ReviewApp!
}

type LocalErrors {
  errors: [String!]!
}

type LocalPageInfo {
  total: Int!
  perPage: Int!
  nextPage: Int!
  previousPage: Int!
}

type k8sPodStatus {
  phase: String
}

type LocalK8sPods {
  status: k8sPodStatus
}

input LocalConfiguration {
  basePath: String
  baseOptions: JSON
}

type k8sServiceMetadata {
  name: String
  namespace: String
  creationTimestamp: String
}

type k8sServiceSpec {
  type: String
  clusterIP: String
  externalIP: String
  ports: JSON
}

type LocalK8sServices {
  metadata: k8sServiceMetadata
  spec: k8sServiceSpec
}

type k8sDeploymentStatus {
  conditions: JSON
}

type localK8sDeployment {
  status: k8sDeploymentStatus
}

type k8sDaemonSetStatus {
  IntMisscheduled: Int
  IntReady: Int
  desiredIntScheduled: Int
}

type localK8sDaemonSet {
  status: k8sDaemonSetStatus
}

type k8sSetStatus {
  readyReplicas: Int
}

type k8sSetSpec {
  replicas: Int
}

type localK8sSet {
  status: k8sSetStatus
  spec: k8sSetSpec
}

type k8sJobStatus {
  failed: Int
  succeeded: Int
}

type k8sJobSpec {
  completions: Int
}

type localK8sJob {
  status: k8sJobStatus
  spec: k8sJobSpec
}

type k8sCronJobStatus {
  active: Int
  lastScheduleTime: String
}

type k8sCronJobSpec {
  suspend: Boolean
}

type localK8sCronJob {
  status: k8sCronJobStatus
  spec: k8sCronJobSpec
}

type LocalK8sWorkloads {
  DeploymentList: [localK8sDeployment]
  DaemonSetList: [localK8sDaemonSet]
  StatefulSetList: [localK8sSet]
  ReplicaSetList: [localK8sSet]
  JobList: [localK8sJob]
  CronJobList: [localK8sCronJob]
}
type k8sNamespaceMetadata {
  name: String
}
type LocalK8sNamespaces {
  metadata: k8sNamespaceMetadata
}

type LocalFluxResourceStatus {
  status: String
  type: String
}

extend type Query {
  environmentApp(page: Int, scope: String): LocalEnvironmentApp
  folder(environment: NestedLocalEnvironmentInput): LocalEnvironmentFolder
  environmentToDelete: LocalEnvironment
  pageInfo: LocalPageInfo
  environmentToRollback: LocalEnvironment
  environmentToStop: LocalEnvironment
  isEnvironmentStopping(environment: LocalEnvironmentInput): Boolean
  isLastDeployment(environment: LocalEnvironmentInput): Boolean
  k8sPods(configuration: LocalConfiguration, namespace: String): [LocalK8sPods]
  k8sServices(configuration: LocalConfiguration): [LocalK8sServices]
  k8sWorkloads(configuration: LocalConfiguration, namespace: String): LocalK8sWorkloads
  fluxKustomizationStatus(
    configuration: LocalConfiguration
    namespace: String
    environmentName: String
  ): LocalFluxResourceStatus
  fluxHelmReleaseStatus(
    configuration: LocalConfiguration
    namespace: String
    environmentName: String
  ): LocalFluxResourceStatus
}

extend type Mutation {
  stopEnvironmentREST(environment: LocalEnvironmentInput): LocalErrors
  deleteEnvironment(environment: LocalEnvironmentInput): LocalErrors
  rollbackEnvironment(environment: LocalEnvironmentInput): LocalErrors
  cancelAutoStop(autoStopUrl: String!): LocalErrors
  setEnvironmentToDelete(environment: LocalEnvironmentInput): LocalErrors
  setEnvironmentToRollback(environment: LocalEnvironmentInput): LocalErrors
  setEnvironmentToStop(environment: LocalEnvironmentInput): LocalErrors
  setEnvironmentToChangeCanary(environment: LocalEnvironmentInput, weight: Int): LocalErrors
  action(environment: LocalEnvironmentInput): LocalErrors
}
